package be.jaisy.osgi.console.service.api.to;

import java.io.Serializable;

public class LogEntryTo implements Serializable{

	private static final long serialVersionUID = 2481985565631503169L;

	private Long bundleId;
	
	private String osgiServiceName;
	
	private String level;

	private String message;
	
	private Throwable exception;
	
	private String time;
	
	public LogEntryTo() {
		super();
	}

	public Long getBundleId() {
		return bundleId;
	}

	public void setBundleId(Long bundleId) {
		this.bundleId = bundleId;
	}

	public Throwable getException() {
		return exception;
	}

	public void setException(Throwable exception) {
		this.exception = exception;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getOsgiServiceName() {
		return osgiServiceName;
	}

	public void setOsgiServiceName(String osgiServiceName) {
		this.osgiServiceName = osgiServiceName;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String toString() {
		StringBuffer sb = new StringBuffer(LogEntryTo.class+" :");
		sb.append("[bundleId="+bundleId+"]");
		sb.append("[level="+level+"]");
		sb.append("[time="+time+"]");
		sb.append("[message="+message+"]");
		sb.append("[osgiServiceName="+osgiServiceName+"]");
		if(exception!=null){
			sb.append("[exception="+exception+":"+exception.getMessage()+"]");
		}
		return sb.toString();
	}

	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((bundleId == null) ? 0 : bundleId.hashCode());
		result = PRIME * result + ((exception == null) ? 0 : exception.hashCode());
		result = PRIME * result + ((level == null) ? 0 : level.hashCode());
		result = PRIME * result + ((message == null) ? 0 : message.hashCode());
		result = PRIME * result + ((osgiServiceName == null) ? 0 : osgiServiceName.hashCode());
		result = PRIME * result + ((time == null) ? 0 : time.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
// commented for GWT
//		if (getClass() != obj.getClass())
//			return false;
		final LogEntryTo other = (LogEntryTo) obj;
		if (bundleId == null) {
			if (other.bundleId != null)
				return false;
		} else if (!bundleId.equals(other.bundleId))
			return false;
		if (exception == null) {
			if (other.exception != null)
				return false;
		} else if (!exception.equals(other.exception))
			return false;
		if (level == null) {
			if (other.level != null)
				return false;
		} else if (!level.equals(other.level))
			return false;
		if (message == null) {
			if (other.message != null)
				return false;
		} else if (!message.equals(other.message))
			return false;
		if (osgiServiceName == null) {
			if (other.osgiServiceName != null)
				return false;
		} else if (!osgiServiceName.equals(other.osgiServiceName))
			return false;
		if (time == null) {
			if (other.time != null)
				return false;
		} else if (!time.equals(other.time))
			return false;
		return true;
	}
	
	
}
